<?php
/**
 * wechat php test
 */
namespace App\Services\Core\Store\Hengxin;

class HengxinService
{


    public static  function getSign($bean,  $tmk) {


        ksort($bean); // 按Key进行排序
        $s='';
        foreach ($bean as $key=>$val) {
            if ($val!= null) {
                $s=$s."&" .$key."=".$val;

            }
        }

        // print_r(substr($s,1,strlen($s)-1));
        $retStr = md5(substr($s,1,strlen($s)-1).$tmk);


        return $retStr;
    }

    public function __construct() {
        //header("Content-Type: application/json; charset=UTF-8");
        $paramsStr = "{\"accountCardNo\":\"123\",\"accountName\":\"123\"}";


        try {
            $paramsObject=json_decode($paramsStr,true);
            $sign = $paramsObject["sign"];
            unset($paramsObject["sign"]);

            $key = "xxx";


            print_r($this->getSign($paramsObject, $key));

        } catch (Exception $e) {

        }

    }




}


